const express = require("express");
const cors = require("cors");
const routes = require("./route");
const app = express();
const port = 3000;
const formidable = require("express-formidable"); // 引入
var bodyParser = require("body-parser");
app.use(bodyParser.json()); // for parsing application/json
app.use(bodyParser.urlencoded({ extended: true })); // for parsing application/x-www-form-urlencoded
// 使用 CORS 中间件处理跨域请求
app.use(cors());
app.use(express.static("./dist"));
// 使用定义的路由
app.use("/api", routes);

app.listen(port, () => {
  console.log(`Node.js 版本管理器后端运行在 http://localhost:${port}`);
});
